{"ast":null,"code":"import _toConsumableArray from\"/Users/iliyagladkov/to-do-react/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js\";import _slicedToArray from\"/Users/iliyagladkov/to-do-react/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import{useState}from'react';import ToDoList from'./components/ToDoList';import ToDoForm from'./components/UI/forms/ToDoForm';import ModalTask from'./components/UI/ModalTask/ModalTask';import MyButtonAdd from'./components/UI/MyButton/MyButtonAdd/MyButtonAdd';import MyModal from'./components/UI/MyModal/MyModal';import'./style/App.css';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";function App(){var _useState=useState(_toConsumableArray(JSON.parse(localStorage.getItem('tasks')))),_useState2=_slicedToArray(_useState,2),toDoItems=_useState2[0],setToDoItems=_useState2[1];var _useState3=useState(false),_useState4=_slicedToArray(_useState3,2),modalForm=_useState4[0],setModalForm=_useState4[1];var _useState5=useState(false),_useState6=_slicedToArray(_useState5,2),modalTask=_useState6[0],setModalTask=_useState6[1];var _useState7=useState({}),_useState8=_slicedToArray(_useState7,2),task=_useState8[0],setTask=_useState8[1];function createToDoItem(newToDoItem){setToDoItems([].concat(_toConsumableArray(toDoItems),[newToDoItem]));setModalForm(false);}function removeToDOItem(toDoItem){setToDoItems(toDoItems.filter(function(toDo){return toDo.id!==toDoItem.id;}));}function getSourceTask(task){var getTask={number:task.number,title:task.title,body:task.body};setTask(getTask);}function setVisibleModal(){setModalTask(true);}localStorage.setItem('tasks',JSON.stringify(toDoItems));return/*#__PURE__*/_jsxs(\"div\",{className:\"App\",children:[/*#__PURE__*/_jsx(\"h1\",{style:{marginTop:'10px'},className:\"header\",children:\"TO-DO LIST\"}),/*#__PURE__*/_jsx(\"hr\",{style:{marginTop:'15px',width:'100%'}}),toDoItems.length===0?/*#__PURE__*/_jsx(\"h2\",{style:{margin:'15px',color:'red'},children:\"To-Do items not found...\"}):/*#__PURE__*/_jsx(ToDoList,{setVisibleModal:setVisibleModal,getTask:getSourceTask,remove:removeToDOItem,toDoItems:toDoItems}),/*#__PURE__*/_jsx(MyButtonAdd,{onClick:function onClick(){return setModalForm(true);}}),/*#__PURE__*/_jsx(MyModal,{visible:modalTask,setVisible:setModalTask,children:/*#__PURE__*/_jsx(ModalTask,{task:task})}),/*#__PURE__*/_jsx(MyModal,{visible:modalForm,setVisible:setModalForm,children:/*#__PURE__*/_jsx(ToDoForm,{create:createToDoItem})})]});}export default App;","map":{"version":3,"names":["useState","ToDoList","ToDoForm","ModalTask","MyButtonAdd","MyModal","App","JSON","parse","localStorage","getItem","toDoItems","setToDoItems","modalForm","setModalForm","modalTask","setModalTask","task","setTask","createToDoItem","newToDoItem","removeToDOItem","toDoItem","filter","toDo","id","getSourceTask","getTask","number","title","body","setVisibleModal","setItem","stringify","marginTop","width","length","margin","color"],"sources":["/Users/iliyagladkov/to-do-react/src/App.js"],"sourcesContent":["import { useState } from 'react';\nimport ToDoList from './components/ToDoList';\nimport ToDoForm from './components/UI/forms/ToDoForm';\nimport ModalTask from './components/UI/ModalTask/ModalTask';\nimport MyButtonAdd from './components/UI/MyButton/MyButtonAdd/MyButtonAdd'\nimport MyModal from './components/UI/MyModal/MyModal';\nimport './style/App.css';\n\nfunction App() {\n\n  const [toDoItems, setToDoItems] = useState([\n    ...JSON.parse(localStorage.getItem('tasks'))\n  ])\n  const [modalForm, setModalForm] = useState(false)\n  const [modalTask, setModalTask] = useState(false)\n  const [task, setTask] = useState({})\n\n  function createToDoItem(newToDoItem) {\n    setToDoItems([...toDoItems, newToDoItem])\n    setModalForm(false)\n  }\n\n  function removeToDOItem(toDoItem) {\n    setToDoItems(toDoItems.filter(toDo => toDo.id !== toDoItem.id))\n  }\n\n  function getSourceTask(task) {\n    const getTask = {\n      number: task.number,\n      title: task.title,\n      body: task.body\n    }\n    setTask(getTask)\n  }\n\n  function setVisibleModal() {\n    setModalTask(true)\n  }\n\n  localStorage.setItem('tasks', JSON.stringify(toDoItems))\n\n  return (\n    <div className=\"App\">\n      <h1 style={{marginTop: '10px'}} className='header'>TO-DO LIST</h1>\n      <hr style={{marginTop: '15px', width: '100%'}}/>\n      {toDoItems.length === 0\n        ?\n        <h2 style={{margin: '15px', color: 'red'}}>To-Do items not found...</h2>\n        :\n        <ToDoList setVisibleModal={setVisibleModal} getTask={getSourceTask} remove={removeToDOItem} toDoItems={toDoItems}></ToDoList>\n      }\n      <MyButtonAdd onClick={() => setModalForm(true)}/>\n      <MyModal\n        visible={modalTask}\n        setVisible={setModalTask}\n      >\n        <ModalTask task={task}/>\n      </MyModal>\n      <MyModal\n        visible={modalForm}\n        setVisible={setModalForm}\n      >\n        <ToDoForm create={createToDoItem}/>\n      </MyModal>\n    </div>\n  );\n}\n\nexport default App;\n"],"mappings":"kPAAA,OAASA,QAAQ,KAAQ,OAAO,CAChC,MAAOC,SAAQ,KAAM,uBAAuB,CAC5C,MAAOC,SAAQ,KAAM,gCAAgC,CACrD,MAAOC,UAAS,KAAM,qCAAqC,CAC3D,MAAOC,YAAW,KAAM,kDAAkD,CAC1E,MAAOC,QAAO,KAAM,iCAAiC,CACrD,MAAO,iBAAiB,CAAC,wFAEzB,QAASC,IAAG,EAAG,CAEb,cAAkCN,QAAQ,oBACrCO,IAAI,CAACC,KAAK,CAACC,YAAY,CAACC,OAAO,CAAC,OAAO,CAAC,CAAC,EAC5C,wCAFKC,SAAS,eAAEC,YAAY,eAG9B,eAAkCZ,QAAQ,CAAC,KAAK,CAAC,yCAA1Ca,SAAS,eAAEC,YAAY,eAC9B,eAAkCd,QAAQ,CAAC,KAAK,CAAC,yCAA1Ce,SAAS,eAAEC,YAAY,eAC9B,eAAwBhB,QAAQ,CAAC,CAAC,CAAC,CAAC,yCAA7BiB,IAAI,eAAEC,OAAO,eAEpB,QAASC,eAAc,CAACC,WAAW,CAAE,CACnCR,YAAY,8BAAKD,SAAS,GAAES,WAAW,GAAE,CACzCN,YAAY,CAAC,KAAK,CAAC,CACrB,CAEA,QAASO,eAAc,CAACC,QAAQ,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